//
//  CourseTypesOfClassesHandler.m
//  mUBB
//
//  Created by Cosmin Stirbu on 1/18/13.
//  Copyright (c) 2013 Cosmin Stirbu. All rights reserved.
//

#import "CourseTypesOfClassesHandler.h"
#import "TypeOfClass.h"
#import "CoursesProtocol.h"

@implementation CourseTypesOfClassesHandler

- (void)handleSuccess:(WSResponse *)response {
    NSArray *typesOfClassesJSON = [response.data objectFromJSONData];
    
    NSMutableArray *typesOfClasses = [NSMutableArray new];
    for (NSDictionary *typeOfClassDict in typesOfClassesJSON) {
        TypeOfClass *typeOfClass = [TypeOfClass new];
        typeOfClass.typeOfClassId = [[typeOfClassDict getJSONObjectForKey:TYPE_OF_CLASS_ID_TAG] integerValue];
        typeOfClass.name = [typeOfClassDict getJSONObjectForKey:TYPE_OF_CLASS_NAME_TAG];
        [typesOfClasses addObject:typeOfClass];
    }
    
    [self.delegate didReceiveTypesOfClassesWithSuccess:typesOfClasses forTicket:self.ticket];
}

- (void)handleError:(WSError *)error {
    [self.delegate didReceiveTypesOfClassesWithFailure:error forTicket:self.ticket];
}

@end
